import { ObjCreate } from "../common/ObjCreate";
import { ImagesConst } from "../../resource/ImagesConst";
import { Language } from "../../../../extend/language/Language";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { ShortcutsKey } from "../../../common/shortcutsKey/ShortcutsKey";
import { GTileList } from "../../../../com/mui/controls/GTileList";
import { ScrollBarDirection } from "../../../../fl/controls/ScrollBarDirection";
import { ShortcutItemRenderer } from "./ShortcutItemRenderer";
import { DataProvider } from "../../../../fl/data/DataProvider";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { EventName } from "../../mvc/EventName";
import { DataEvent } from "../../events/DataEvent";
import { KeyMapData } from "../../../common/shortcutsKey/KeyMapData";
import { Vector } from "../../../../__AS3__/vec/Vector";
type int = number;
//class ShortcutPanel
    
    export  class ShortcutPanel /* flash.display.Sprite */
    {
        constructor()
        {
            
            this.createUI();
            return;
        }

        /* internal  */createUI(): void
        {
            ObjCreate.createBg(3, 0, 202, 290, this);
            ObjCreate.createBg(3, -3, 205, 25, this, ImagesConst.RbListHeader);
            ObjCreate.createBg(207, 0, 202, 290, this);
            ObjCreate.createBg(207, -3, 205, 25, this, ImagesConst.RbListHeader);
            ObjCreate.createTextField(Language.getString(33050), 20, 5, 60, 20, this, GlobalStyle.textFormat6);
            ObjCreate.createTextField(Language.getString(33051), 125, 5, 60, 20, this, GlobalStyle.textFormat6);
            ObjCreate.createTextField(Language.getString(33052), 222, 5, 60, 20, this, GlobalStyle.textFormat6);
            ObjCreate.createTextField(Language.getString(33051), 327, 5, 60, 20, this, GlobalStyle.textFormat6);
            var loc1=ShortcutsKey.instance.moduleAry;
            this._leftList = new GTileList();
            this._leftList.setSize(195, 260);
            this._leftList.columnWidth = 195;
            this._leftList.rowHeight = 29;
            this._leftList.direction = ScrollBarDirection.VERTICAL;
            this._leftList.horizontalGap = 0;
            this._leftList.verticalGap = 0;
            this._leftList.styleName = "TileList";
            this._leftList.setStyle("skin", new Object /* flash.display.Bitmap */());
            this._leftList.setStyle("cellRenderer", ShortcutItemRenderer);
            this._leftList.move(3, 30);
            addChild(this._leftList);
            this._leftList.dataProvider = new DataProvider(loc1);
            this._leftList.drawNow();
            var loc2=ShortcutsKey.instance.skillsAry;
            this._rightList = new GTileList();
            this._rightList.setSize(195, 260);
            this._rightList.columnWidth = 195;
            this._rightList.rowHeight = 29;
            this._rightList.direction = ScrollBarDirection.VERTICAL;
            this._rightList.horizontalGap = 0;
            this._rightList.verticalGap = 0;
            this._rightList.styleName = "TileList";
            this._rightList.setStyle("skin", new Object /* flash.display.Bitmap */());
            this._rightList.setStyle("cellRenderer", ShortcutItemRenderer);
            this._rightList.move(205, 30);
            addChild(this._rightList);
            this._rightList.dataProvider = new DataProvider(loc2);
            this._rightList.drawNow();
            var loc3=ObjCreate.createGButton(Language.getString(33053), 20, 300, 70, 25, this);
            loc3.addEventListener(flash.events.MouseEvent.CLICK, this.onDefaultBtnClickHandler);
            var loc4;
            (loc4 = ObjCreate.createGButton(Language.getString(33054), 145, 300, 50, 25, this)).addEventListener(flash.events.MouseEvent.CLICK, this.onSureBtnClickHandler);
            var loc5;
            (loc5 = ObjCreate.createGButton(Language.getString(33055), 215, 300, 50, 25, this)).addEventListener(flash.events.MouseEvent.CLICK, this.onCancelBtnClickHandler);
            Dispatcher.addEventListener(EventName.ShortcutsUpdate, this.onShortcutsUpdateHandler);
            return;
        }

        /* internal  */onShortcutsUpdateHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data as KeyMapData;
            if (loc1) 
            {
                if (ShortcutsKey.instance.skillsAry.indexOf(loc1) > -1) 
                {
                    this._rightList.invalidateItem(loc1);
                }
                else if (ShortcutsKey.instance.moduleAry.indexOf(loc1) > -1) 
                {
                    this._leftList.invalidateItem(loc1);
                }
            }
            return;
        }

        /* internal  */onDefaultBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            ShortcutsKey.instance.setDefaultShortcutsKey();
            this._rightList.invalidateList();
            this._leftList.invalidateList();
            Dispatcher.dispatchEvent(new DataEvent(EventName.SaveShortcutSetter));
            return;
        }

        /* internal  */onSureBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.SaveShortcutSetter));
            return;
        }

        /* internal  */onCancelBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            this.setRecoverySetter();
            return;
        }

        public setRecoverySetter(): void
        {
            ShortcutsKey.instance.recoverySetter();
            this._rightList.invalidateList();
            this._leftList.invalidateList();
            return;
        }

        /* internal */ /* const */firstX: int=15;

        /* internal */ /* const */firstY: int=15;

        /* internal */ /* var */_itemVector: Vector.<Object>;

        /* internal */ /* var */_leftList: GTileList;

        /* internal */ /* var */_rightList: GTileList;
    }
